import { _decorator, Component, Director, find,director, Node,Game } from 'cc';
import { EventMgr } from '../EventMgr/EventMgr';
import { AudioMgr } from '../AudioMgr/AudioMgr';
const { ccclass, property,executionOrder } = _decorator;

@ccclass('Root')
@executionOrder(-1)
export class Root extends Component {

   public static Inst:Root|null=null;

   @property curSceneLv:number=1;
   @property maxLv:number=5;
    @property isRelease:boolean=true;

    onLoad() {
        if(Root.Inst==null){

        Director.instance.addPersistRootNode(this.node);
        console.log("root onload");
        Root.Inst=this;
        }else {
            throw new Error("only one root node");
        }
    }

    setSceneLv(lv:number){
        this.curSceneLv=lv;
    }

    addSceneLv(){
        if(this.curSceneLv<this.maxLv){
            this.curSceneLv+=1;
        }
    }

    loadNextLv(){
        director.loadScene("mygame"+this.curSceneLv,()=>{
        });
    }

}


